Skip to contentSkip to conversation

Change in openvpn[master]: override ai_family if 'local' numeric address was specified

Openvpn-devel ordex (Code Review) 1 participant 4 messages Nov 15, 2023 – Sep 24, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1700055887000.I8c9ec61af9e786ec284e756ec3a77a959c79f49b@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/437?usp=email

to review the following change.

Change subject: override ai_family if 'local' numeric address was specified
......................................................................

override ai_family if 'local' numeric address was specified

This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option.

Change-Id I8c9ec61af9e786ec284e756ec3a77a959c79f49b

---
M src/openvpn/socket.c

1 file changed, 11 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/37/437/1

src/openvpn/socket.c +11 -2
index 5d9e111..ffd8daf 100644
@@ -489,9 +489,8 @@
         sig_info = &sigrec;
     }
 
-    /* try numeric ipv6 addr first */
+    /* try numeric ip addr first */
     CLEAR(hints);
-    hints.ai_family = ai_family;
     hints.ai_flags = AI_NUMERICHOST;
 
     if (flags & GETADDR_PASSIVE)
@@ -519,6 +518,10 @@
         const char *fmt;
         int level = 0;
 
+        /* this is not a numeric IP, therefore force resolution using the
+         * provided ai_family */
+        hints.ai_family = ai_family;
+
         if (hostname && (flags & GETADDR_RANDOMIZE))
         {
             hostname = hostname_randomize(hostname, &gc);
@@ -1120,7 +1123,9 @@
             /* force binding IPv6-only if an address was specified
              * an it is a IPv6 */
             if (sock->local_host && ai_family == AF_INET6)
+            {
                 v6only = true;
+            }
 
             socket_bind(sock->sd, sock->info.lsa->bind_local,
                         ai_family, "TCP/UDP", v6only);
@@ -1712,6 +1717,10 @@
                 sock->local_host, sock->local_port,
                 gai_strerror(status));
         }
+
+        /* the resolved 'local entry' might have a different family than what
+         * was globally configured */
+        sock->info.af = sock->info.lsa->bind_local->ai_family;
     }
 
     gc_free(&gc);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/437?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8c9ec61af9e786ec284e756ec3a77a959c79f49b
Gerrit-Change-Number: 437
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

ordex has abandoned this change. ( http://gerrit.openvpn.net/c/openvpn/+/437?usp=email )

Change subject: override ai_family if 'local' numeric address was specified
......................................................................

Abandoned
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/437?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8c9ec61af9e786ec284e756ec3a77a959c79f49b
Gerrit-Change-Number: 437
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: abandon

#3 lore raw
In reply to a message not in the archive

ordex has restored this change. ( http://gerrit.openvpn.net/c/openvpn/+/437?usp=email )

Change subject: override ai_family if 'local' numeric address was specified
......................................................................

Restored
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/437?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8c9ec61af9e786ec284e756ec3a77a959c79f49b
Gerrit-Change-Number: 437
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: restore

#4 lore raw
In reply to a message not in the archive

ordex has abandoned this change. ( http://gerrit.openvpn.net/c/openvpn/+/437?usp=email )

Change subject: override ai_family if 'local' numeric address was specified
......................................................................

Abandoned
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/437?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8c9ec61af9e786ec284e756ec3a77a959c79f49b
Gerrit-Change-Number: 437
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: abandon